package com.example.voicepad.ui;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

import com.workingteams.mobile.voicepad.R;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	
		Button recordingButton = (Button) findViewById(R.id.buttonStartRecording);

		PackageManager pm = getPackageManager();
		List<ResolveInfo> activities = pm
				.queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
		if (activities.size() == 0) {
			recordingButton.setEnabled(false);
			recordingButton.setText("Recognizer not present");
		}

	}

	/**
	 * Handle the action of the button being clicked
	 */
	public void buttonStartRecordingAction(View v) {
		Intent intent = new Intent(this, RecordingActivity.class);
		startActivity(intent);
	}
	
	public void buttonViewNotesAction(View v) {
		Intent intent = new Intent(this, ViewNotesActivity.class);
		startActivity(intent);
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
